<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ca="http://java.sun.com/jsf/composite/cashSummery"
                xmlns:pe="http://primefaces.org/ui/extensions"
                xmlns:cre="http://java.sun.com/jsf/composite/cashier">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:form >

            <p:panel  style="border: none;">
                <f:facet name="header" >

                    <p:outputLabel value="#{creditSummeryController.institution.name} "/> 
                    <p:outputLabel value=" Credit Summary - Detail"/><br/>

                    <h:panelGrid columns="2" styleClass="noPrintButton">

                        <h:outputLabel value="From Date"/>
                        <p:calendar id="frmDate" value="#{creditSummeryController.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>

                        <h:outputLabel value="To Date"/>
                        <p:calendar id="toDate" value="#{creditSummeryController.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>
                        <h:outputLabel value="Credit Company"/>
                        <p:autoComplete styleClass="noPrintButton" id="creditCom" forceSelection="true" value="#{creditSummeryController.institution}" 
                                        completeMethod="#{creditCompanyController.completeCredit}" var="ix" itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;">

                        </p:autoComplete>
                        <h:outputLabel value="Vat Reg. No"/>
                        <p:inputText value="#{creditSummeryController.vatRegNo}" autocomplete="off" />
                        <h:outputLabel value="Invoice No"/>
                        <p:inputText value="#{creditSummeryController.invoceNo}" autocomplete="off" />
                        <h:outputLabel value="With Footer"/>
                        <p:selectBooleanCheckbox value="#{creditSummeryController.withFooter}" />
                    </h:panelGrid>
                    <h:panelGrid columns="5" styleClass="noPrintButton">
                        <p:spacer width="100" height="1"/>   
                        <p:commandButton id="btnRefresh" value="Refresh" ajax="false"  styleClass="noPrintButton" style="float: right;" action="#{creditSummeryController.createCreditDueTable}" />
                        <p:defaultCommand target="btnRefresh"/>

                        <p:commandButton ajax="false" value="Print"  styleClass="noPrintButton" style="float: right;" >
                            <p:printer target="panelPrint" />
                        </p:commandButton>
                        <p:commandButton actionListener="#{creditSummeryController.createCreditDueTable}" ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" >
                            <pe:exporter type="xlsx" target="safrin" fileName="credit_dep_by_bill"  />
                        </p:commandButton>

                    </h:panelGrid>
                </f:facet>

            </p:panel>    
            <p:panel id="panelPrint" styleClass="noBorder summeryBorder">

                <p:dataTable id="safrin" value="#{creditSummeryController.creditBills}" var="b" >  
                    <f:facet name="header">
                        <h:outputLabel value="Report By Bill"/>
                        <h:outputLabel value="#{creditSummeryController.institution.name}" style="white-space: pre-line"/>
                        <br/>
                        <h:outputLabel value="From  :  "/>
                        <h:outputLabel value="#{creditSummeryController.fromDate}"  >
                            <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                        </h:outputLabel>
                        <p:spacer width="30" height="1"/>
                        <h:outputLabel value="To "/>
                        <h:outputLabel value="#{creditSummeryController.toDate}"  >
                            <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                        </h:outputLabel>
                    </f:facet>
                    <p:column>
                        <f:facet name="header">
                            <p:outputLabel value="Bill No" />
                        </f:facet>
                        <h:outputLabel value="#{b.insId}" />
                    </p:column>                      
                    <p:column>
                        <f:facet name="header">
                            <p:outputLabel value="Patient Name" />
                        </f:facet>
                        <h:outputLabel value="#{b.patient.person.nameWithTitle}"/>
                    </p:column>
                    <p:column style="text-align: right;">
                        <f:facet name="header">
                            <p:outputLabel value="Non-Taxable Value" />
                        </f:facet>
                        <h:outputLabel value="#{b.netTotal-b.vatCalulatedAmount}" >
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{creditSummeryController.total-creditSummeryController.totalVatCalculatedValue}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                    <p:column style="text-align: right;">
                        <f:facet name="header">
                            <p:outputLabel value="Vat Liable Value" />
                        </f:facet>
                        <h:outputLabel value="#{b.vatCalulatedAmount}" >
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{creditSummeryController.totalVatCalculatedValue}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                    <p:column style="text-align: right;">
                        <f:facet name="header">
                            <p:outputLabel value="Vat" />
                        </f:facet>
                        <h:outputLabel value="#{b.vat}" >
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{creditSummeryController.totalVat}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                    <p:column style="text-align: right;">
                        <f:facet name="header">
                            <p:outputLabel value="Value" />
                        </f:facet>
                        <h:outputLabel value="#{b.netTotal+b.vat}" >
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{creditSummeryController.total+creditSummeryController.totalVat}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>
                </p:dataTable>

            </p:panel>

            <p:panel >
                <p:commandButton value="Print" ajax="false" action="#">
                    <p:printer target="gpBillPreviewPaysheet" ></p:printer>
                </p:commandButton>
                <p:commandButton value="Print(Tax Invoice)" ajax="false" action="#">
                    <p:printer target="gpBillPreviewPaysheet2" ></p:printer>
                </p:commandButton>
                <p:panel   id="gpBillPreviewPaysheet"  styleClass="noBorder summeryBorder">
                    <cre:credit_letter bills="#{creditSummeryController.creditBills}" con="#{creditSummeryController}"/>
                </p:panel>
                <p:spacer height="550" />
                <p:panel   id="gpBillPreviewPaysheet2"  styleClass="noBorder summeryBorder">
                    <cre:credit_letter_vat_invoice bills="#{creditSummeryController.creditBills}" con="#{creditSummeryController}"/>
                </p:panel>
            </p:panel>
        </h:form>
    </ui:define>


</ui:composition>
